Calculate dsrs for local authorities
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.2 ✓ purrr 0.3.4
## ✓ tibble 3.0.4 ✓ dplyr 1.0.2
## ✓ tidyr 1.1.2 ✓ stringr 1.4.0
## ✓ readr 1.4.0 ✓ forcats 0.5.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(devtools)
## Loading required package: usethis
URL <- "https://github.com/julianflowers12/test-and-trace/blob/master/create_case_dsr.R?raw=TRUE"
source_url(URL)
## ℹ SHA-1 hash of file is d8b2d76c5aa803f523bbee1237871b0d069040af
test <- case_dsrs_las(area = "ltla")
## Loading required package: data.table
##
## Attaching package: 'data.table'
## The following objects are masked from 'package:dplyr':
##
## between, first, last
## The following object is masked from 'package:purrr':
##
## transpose
## Loading required package: readxl
## Loading required package: PHEindicatormethods
## Loading required package: phutils
##
## Attaching package: 'phutils'
## The following object is masked from 'package:data.table':
##
## between
## The following object is masked from 'package:dplyr':
##
## between
## The following object is masked from 'package:purrr':
##
## splice
## `summarise()` regrouping output by 'Code', 'Name', 'gender', 'ageband' (override with `.groups` argument)
tail(test$dsr)
## # A tibble: 6 x 10
## # Groups: areaName, date [6]
## areaName date total_count total_pop value lowercl uppercl confidence
## <chr> <date> <int> <dbl> <dbl> <dbl> <dbl> <chr>
## 1 York 2020-11-16 350 421236 81.5 73.0 90.8 95%
## 2 York 2020-11-17 323 421236 76.2 67.9 85.2 95%
## 3 York 2020-11-18 301 421236 70.9 62.9 79.5 95%
## 4 York 2020-11-19 288 421236 68.7 60.8 77.3 95%
## 5 York 2020-11-20 276 421236 65.7 58.0 74.1 95%
## 6 York 2020-11-21 277 421236 66.5 58.7 75.0 95%
## # … with 2 more variables: statistic <chr>, method <chr>
Tier 1
unique(test$dsr$areaName)
## [1] "Adur"
## [2] "Allerdale"
## [3] "Amber Valley"
## [4] "Arun"
## [5] "Ashfield"
## [6] "Ashford"
## [7] "Aylesbury Vale"
## [8] "Babergh"
## [9] "Barking and Dagenham"
## [10] "Barnet"
## [11] "Barnsley"
## [12] "Barrow-in-Furness"
## [13] "Basildon"
## [14] "Basingstoke and Deane"
## [15] "Bassetlaw"
## [16] "Bath and North East Somerset"
## [17] "Bedford"
## [18] "Bexley"
## [19] "Birmingham"
## [20] "Blaby"
## [21] "Blackburn with Darwen"
## [22] "Blackpool"
## [23] "Bolsover"
## [24] "Bolton"
## [25] "Boston"
## [26] "Bournemouth, Christchurch and Poole"
## [27] "Bracknell Forest"
## [28] "Bradford"
## [29] "Braintree"
## [30] "Breckland"
## [31] "Brent"
## [32] "Brentwood"
## [33] "Brighton and Hove"
## [34] "Bristol, City of"
## [35] "Broadland"
## [36] "Bromley"
## [37] "Bromsgrove"
## [38] "Broxbourne"
## [39] "Broxtowe"
## [40] "Burnley"
## [41] "Bury"
## [42] "Calderdale"
## [43] "Cambridge"
## [44] "Camden"
## [45] "Cannock Chase"
## [46] "Canterbury"
## [47] "Carlisle"
## [48] "Castle Point"
## [49] "Central Bedfordshire"
## [50] "Charnwood"
## [51] "Chelmsford"
## [52] "Cheltenham"
## [53] "Cherwell"
## [54] "Cheshire East"
## [55] "Cheshire West and Chester"
## [56] "Chesterfield"
## [57] "Chichester"
## [58] "Chiltern"
## [59] "Chorley"
## [60] "Colchester"
## [61] "Copeland"
## [62] "Corby"
## [63] "Cornwall and Isles of Scilly"
## [64] "Cotswold"
## [65] "County Durham"
## [66] "Coventry"
## [67] "Craven"
## [68] "Crawley"
## [69] "Croydon"
## [70] "Dacorum"
## [71] "Darlington"
## [72] "Dartford"
## [73] "Daventry"
## [74] "Derby"
## [75] "Derbyshire Dales"
## [76] "Doncaster"
## [77] "Dorset"
## [78] "Dover"
## [79] "Dudley"
## [80] "Ealing"
## [81] "East Cambridgeshire"
## [82] "East Devon"
## [83] "East Hampshire"
## [84] "East Hertfordshire"
## [85] "East Lindsey"
## [86] "East Northamptonshire"
## [87] "East Riding of Yorkshire"
## [88] "East Staffordshire"
## [89] "East Suffolk"
## [90] "Eastbourne"
## [91] "Eastleigh"
## [92] "Eden"
## [93] "Elmbridge"
## [94] "Enfield"
## [95] "Epping Forest"
## [96] "Epsom and Ewell"
## [97] "Erewash"
## [98] "Exeter"
## [99] "Fareham"
## [100] "Fenland"
## [101] "Folkestone and Hythe"
## [102] "Forest of Dean"
## [103] "Fylde"
## [104] "Gateshead"
## [105] "Gedling"
## [106] "Gloucester"
## [107] "Gosport"
## [108] "Gravesham"
## [109] "Great Yarmouth"
## [110] "Greenwich"
## [111] "Guildford"
## [112] "Hackney and City of London"
## [113] "Halton"
## [114] "Hambleton"
## [115] "Hammersmith and Fulham"
## [116] "Harborough"
## [117] "Haringey"
## [118] "Harlow"
## [119] "Harrogate"
## [120] "Harrow"
## [121] "Hart"
## [122] "Hartlepool"
## [123] "Hastings"
## [124] "Havant"
## [125] "Havering"
## [126] "Herefordshire, County of"
## [127] "Hertsmere"
## [128] "High Peak"
## [129] "Hillingdon"
## [130] "Hinckley and Bosworth"
## [131] "Horsham"
## [132] "Hounslow"
## [133] "Huntingdonshire"
## [134] "Hyndburn"
## [135] "Ipswich"
## [136] "Isle of Wight"
## [137] "Islington"
## [138] "Kensington and Chelsea"
## [139] "Kettering"
## [140] "King's Lynn and West Norfolk"
## [141] "Kingston upon Hull, City of"
## [142] "Kingston upon Thames"
## [143] "Kirklees"
## [144] "Knowsley"
## [145] "Lambeth"
## [146] "Lancaster"
## [147] "Leeds"
## [148] "Leicester"
## [149] "Lewes"
## [150] "Lewisham"
## [151] "Lichfield"
## [152] "Lincoln"
## [153] "Liverpool"
## [154] "Luton"
## [155] "Maidstone"
## [156] "Maldon"
## [157] "Malvern Hills"
## [158] "Manchester"
## [159] "Mansfield"
## [160] "Medway"
## [161] "Melton"
## [162] "Mendip"
## [163] "Merton"
## [164] "Mid Devon"
## [165] "Mid Suffolk"
## [166] "Mid Sussex"
## [167] "Middlesbrough"
## [168] "Milton Keynes"
## [169] "Mole Valley"
## [170] "New Forest"
## [171] "Newark and Sherwood"
## [172] "Newcastle upon Tyne"
## [173] "Newcastle-under-Lyme"
## [174] "Newham"
## [175] "North Devon"
## [176] "North East Derbyshire"
## [177] "North East Lincolnshire"
## [178] "North Hertfordshire"
## [179] "North Kesteven"
## [180] "North Lincolnshire"
## [181] "North Norfolk"
## [182] "North Somerset"
## [183] "North Tyneside"
## [184] "North Warwickshire"
## [185] "North West Leicestershire"
## [186] "Northampton"
## [187] "Northumberland"
## [188] "Norwich"
## [189] "Nottingham"
## [190] "Nuneaton and Bedworth"
## [191] "Oadby and Wigston"
## [192] "Oldham"
## [193] "Oxford"
## [194] "Pendle"
## [195] "Peterborough"
## [196] "Plymouth"
## [197] "Portsmouth"
## [198] "Preston"
## [199] "Reading"
## [200] "Redbridge"
## [201] "Redcar and Cleveland"
## [202] "Redditch"
## [203] "Reigate and Banstead"
## [204] "Ribble Valley"
## [205] "Richmond upon Thames"
## [206] "Richmondshire"
## [207] "Rochdale"
## [208] "Rochford"
## [209] "Rossendale"
## [210] "Rother"
## [211] "Rotherham"
## [212] "Rugby"
## [213] "Runnymede"
## [214] "Rushcliffe"
## [215] "Rushmoor"
## [216] "Rutland"
## [217] "Ryedale"
## [218] "Salford"
## [219] "Sandwell"
## [220] "Scarborough"
## [221] "Sedgemoor"
## [222] "Sefton"
## [223] "Selby"
## [224] "Sevenoaks"
## [225] "Sheffield"
## [226] "Shropshire"
## [227] "Slough"
## [228] "Solihull"
## [229] "Somerset West and Taunton"
## [230] "South Bucks"
## [231] "South Cambridgeshire"
## [232] "South Derbyshire"
## [233] "South Gloucestershire"
## [234] "South Hams"
## [235] "South Holland"
## [236] "South Kesteven"
## [237] "South Lakeland"
## [238] "South Norfolk"
## [239] "South Northamptonshire"
## [240] "South Oxfordshire"
## [241] "South Ribble"
## [242] "South Somerset"
## [243] "South Staffordshire"
## [244] "South Tyneside"
## [245] "Southampton"
## [246] "Southend-on-Sea"
## [247] "Southwark"
## [248] "Spelthorne"
## [249] "St Albans"
## [250] "St. Helens"
## [251] "Stafford"
## [252] "Staffordshire Moorlands"
## [253] "Stevenage"
## [254] "Stockport"
## [255] "Stockton-on-Tees"
## [256] "Stoke-on-Trent"
## [257] "Stratford-on-Avon"
## [258] "Stroud"
## [259] "Sunderland"
## [260] "Surrey Heath"
## [261] "Sutton"
## [262] "Swale"
## [263] "Swindon"
## [264] "Tameside"
## [265] "Tamworth"
## [266] "Tandridge"
## [267] "Teignbridge"
## [268] "Telford and Wrekin"
## [269] "Tendring"
## [270] "Test Valley"
## [271] "Tewkesbury"
## [272] "Thanet"
## [273] "Three Rivers"
## [274] "Thurrock"
## [275] "Tonbridge and Malling"
## [276] "Torbay"
## [277] "Torridge"
## [278] "Tower Hamlets"
## [279] "Trafford"
## [280] "Tunbridge Wells"
## [281] "Uttlesford"
## [282] "Vale of White Horse"
## [283] "Wakefield"
## [284] "Walsall"
## [285] "Waltham Forest"
## [286] "Wandsworth"
## [287] "Warrington"
## [288] "Warwick"
## [289] "Watford"
## [290] "Waverley"
## [291] "Wealden"
## [292] "Wellingborough"
## [293] "Welwyn Hatfield"
## [294] "West Berkshire"
## [295] "West Devon"
## [296] "West Lancashire"
## [297] "West Lindsey"
## [298] "West Oxfordshire"
## [299] "West Suffolk"
## [300] "Westminster"
## [301] "Wigan"
## [302] "Wiltshire"
## [303] "Winchester"
## [304] "Windsor and Maidenhead"
## [305] "Wirral"
## [306] "Woking"
## [307] "Wokingham"
## [308] "Wolverhampton"
## [309] "Worcester"
## [310] "Worthing"
## [311] "Wychavon"
## [312] "Wycombe"
## [313] "Wyre"
## [314] "Wyre Forest"
## [315] "York"
t1 <- c("Cornwall and Isles of Scilly", "Isle of Wight", "Liverpool", "Swale", "Kingston upon Hull, City of", "Manchester", "South Cambridgeshire")
dsr_plot <- test$dsr %>%
#filter(areaName %in% t1) %>%
ggplot(aes(date, value, colour = areaName)) +
geom_line(show.legend = FALSE) +
labs(y = "Standardised case rate",
x = "Date",
title = "Age standardised 7-day rolling case rates per 100,000") +
scale_x_date(breaks = "months") +
theme(axis.text.x = element_text(angle = 45, hjust = 1),
plot.title.position = "plot",
panel.background = element_blank())
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
ggplotly(dsr_plot)